package com.anjubao.parking.municipal.roadside.config.quartz;

import com.anjubao.parking.municipal.roadside.config.quartz.job.ParkingIllegalCheckJob;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;

@Configuration
public class JobTriggerConfig {

    @Bean
    public JobDetailFactoryBean parkingIllegalJobDetail() {
        JobDetailFactoryBean jobDetailFactoryBean = new JobDetailFactoryBean();
        jobDetailFactoryBean.setJobClass(ParkingIllegalCheckJob.class);
        return jobDetailFactoryBean;
    }

    @Bean(autowire = Autowire.BY_NAME)
    public CronTriggerFactoryBean parkingIllegalTrigger() {
        CronTriggerFactoryBean triggerFactoryBean = new CronTriggerFactoryBean();
        triggerFactoryBean.setJobDetail(parkingIllegalJobDetail().getObject());
        triggerFactoryBean.setCronExpression("0/10 * * * * ?");
        return triggerFactoryBean;
    }
}
